package com.netease.financial.internal.di.modules;

import com.netease.financial.domain.Factory;
import com.netease.financial.domain.executor.PostExecutionThread;
import com.netease.financial.domain.executor.ThreadExecutor;
import com.netease.financial.domain.interactor.GetActivityPageInfo;
import com.netease.financial.domain.interactor.GetAppUpdateInfo;
import com.netease.financial.domain.interactor.GetUnreadSiteMessageCount;
import com.netease.financial.domain.interactor.Logout;
import com.netease.financial.domain.interactor.UseCase;
import com.netease.financial.domain.repository.NfsRepository;
import com.netease.financial.internal.di.ActivityScope;
import com.netease.financial.module.asset.AssetPresenter;
import com.netease.financial.module.asset.AssetPresenterImpl;
import com.netease.financial.module.home.HomePresenter;
import com.netease.financial.module.home.HomePresenterImpl;
import com.netease.financial.module.information.InformationPresenter;
import com.netease.financial.module.information.InformationPresenterImpl;
import com.netease.financial.module.main.MainPresenter;
import com.netease.financial.module.main.MainPresenterImpl;
import com.netease.financial.module.product.ProductPresenter;
import com.netease.financial.module.product.ProductPresenterImpl;

import javax.inject.Named;

import dagger.Module;
import dagger.Provides;

/**
 * Dagger module that provides main related collaborators.
 */
@Module
public class MainModule {

    // 用户accessToken
    private final Factory<String> accessToken;

    // 设备类型/android或ios等
    private final String device;

    // 应用当前的versionCode
    private final int versionCode;

    private final String appSecret;

    public MainModule(Factory<String> accessToken, String device, int versionCode, String appSecret) {
        this.accessToken = accessToken;
        this.device = device;
        this.versionCode = versionCode;
        this.appSecret = appSecret;
    }

    @Provides
    @ActivityScope
    MainPresenter provideMainPresenter(MainPresenterImpl mainPresenter) {
        return mainPresenter;
    }

    @Provides
    @ActivityScope
    HomePresenter provideHomePresenter(HomePresenterImpl homePresenter) {
        return homePresenter;
    }

    @Provides
    @ActivityScope
    ProductPresenter provideProductPresenter(ProductPresenterImpl productPresenter) {
        return productPresenter;
    }

    @Provides
    @ActivityScope
    InformationPresenter provideInformationPresenter(InformationPresenterImpl informationPresenter) {
        return informationPresenter;
    }

    @Provides
    @ActivityScope
    AssetPresenter provideAssetPresenter(AssetPresenterImpl assetPresenter) {
        return assetPresenter;
    }

    @Provides
    @ActivityScope
    @Named("app_update_info")
    UseCase provideGetAppUpdateInfoUseCase(NfsRepository nfsRepository,
                                           ThreadExecutor threadExecutor,
                                           PostExecutionThread postExecutionThread) {
        return new GetAppUpdateInfo(device, versionCode, nfsRepository, threadExecutor, postExecutionThread);
    }

    @Provides
    @ActivityScope
    @Named("unread_site_message_count")
    UseCase provideGetUnreadSiteMessageCountUseCase(NfsRepository nfsRepository,
                                                    ThreadExecutor threadExecutor,
                                                    PostExecutionThread postExecutionThread) {
        return new GetUnreadSiteMessageCount(accessToken, nfsRepository, threadExecutor, postExecutionThread);
    }

    @Provides
    @ActivityScope
    @Named("logout")
    UseCase provideLogoutUseCase(NfsRepository nfsRepository,
                                 ThreadExecutor threadExecutor,
                                 PostExecutionThread postExecutionThread) {
        return new Logout(accessToken, appSecret, nfsRepository, threadExecutor, postExecutionThread);
    }

    @Provides
    @ActivityScope
    @Named("activity_page")
    UseCase provideActivityPageUseCase(NfsRepository nfsRepository,
                                       ThreadExecutor threadExecutor,
                                       PostExecutionThread postExecutionThread) {
        return new GetActivityPageInfo(nfsRepository, threadExecutor, postExecutionThread);
    }

}